﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class VirtualRuTrainNumberMap : EntityTypeConfiguration<VirtualRuTrainNumber>
    {
        public VirtualRuTrainNumberMap()
        {
            ToTable("VirtualRuTrainNumbers");
            HasKey(virtualRuTrainNumber => virtualRuTrainNumber.Id);

            Property(virtualRuTrainNumber => virtualRuTrainNumber.TrainNumber).IsRequired().HasMaxLength(10);
            HasRequired(virtualRuTrainNumber => virtualRuTrainNumber.Ru).WithMany(ru => ru.RuTrainNumbers);
            HasRequired(virtualRuTrainNumber => virtualRuTrainNumber.VirtualRu).WithMany(ru => ru.VirtualRuTrainNumbers);
            Property(virtualRuTrainNumber => virtualRuTrainNumber.ValidFrom).IsOptional();
            Property(virtualRuTrainNumber => virtualRuTrainNumber.ValidTo).IsOptional();
        }
    }
}